package resp

import "view-crawler-backend/internal/constant"

// Response 全局返回对象
type Response struct {
	Code string `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data"`
}

func BuildResponse(code string, msg string, data any) *Response {
	return &Response{Code: code, Msg: msg, Data: data}
}

func BuildSuccessResponse(data any) *Response {
	return BuildResponse(constant.SUCCESS.Code, constant.SUCCESS.Msg, data)
}

func BuildErrorResponse(code constant.Code) *Response {
	return BuildResponse(code.Code, code.Msg, nil)
}
